package controller.user.shoppingCart;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import service.Impl.ShopCartServiceImpl;
import util.ResultUtil;

import java.io.IOException;

@WebServlet("/user/shoppingCart/sub")
public class ShopCartDelController extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        ShopCartServiceImpl service=new ShopCartServiceImpl();
        String dId=req.getParameter("dishId");
        String sId=req.getParameter("setmealId");
        Integer dishId=null;
        Integer setmealId=null;
        if(dId!=null&&dId!=""){
            dishId= Integer.valueOf(dId);
        }
        if(sId!=null&&sId!=""){
            setmealId= Integer.valueOf(sId);
        }
        service.delete(dishId,setmealId);
        String json= ResultUtil.getJSON(null);
        resp.getWriter().write(json);
    }
}
